package com.shop2cn.iapi.prodstockmgr.testcase;

import java.io.IOException;
import java.util.Arrays;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.prodstockmgr.parameter.CatalogDto;
import com.shop2cn.iapi.prodstockmgr.parameter.StockOutOnDeliveryBean;
import com.shop2cn.iapi.prodstockmgr.service.StockOutOnDeliveryCall;
import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ProductDetailsDto;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.AddAgentProductCallService;
import com.ymttest.business.service.GodfreightmgrService;
import com.ymttest.database.model.stockmgr.agentinventorysku;
import com.ymttest.database.model.stockmgr.agentinventoryskuExample;
import com.ymttest.database.sqlwapper.stockmgr.agentinventoryskuWapper;
import com.ymttest.utils.AgentUsers;
import com.ymttest.utils.TestDataManager;

/**
 * 发货出库Test FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_StockOutOnDelivery {
	private static StockOutOnDeliveryBean stockoutondeliveryBean;
	private static StockOutOnDeliveryCall stockoutondeliveryCall;
	
	agentinventoryskuExample example=new agentinventoryskuExample();
	agentinventoryskuWapper sku=new agentinventoryskuWapper();
	

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("发货出库Test");
		try {
			GodfreightmgrService.deleteBySellerId(rootUserId);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Before
	public void caseUp() {
		stockoutondeliveryBean = new StockOutOnDeliveryBean();
		stockoutondeliveryCall = new StockOutOnDeliveryCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(stockoutondeliveryCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	// 渠道商
	private static int rootUserId = AgentUsers.rootUserId;
	private static String rootUserName = "NickautoTest";
	// 渠道商->代理商1
	private static int agentUserId1 = AgentUsers.agentUserId1;
	private static String agentUserName1 = "NickautoTest";
	// vip渠道
	private static int vipRootUserId = AgentUsers.vipRootUserId;
	private static String vipRootUserName = "NickautoTest";
	private static int csId = AgentUsers.csId;
	// vip渠道->代理
	private static int vipAgentUserId1 = AgentUsers.vipAgentUserId1;
	private static String vipAgentUserName1 = "dgsq408897016";
	private static int csIpd1 = AgentUsers.csId1;

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_StockOutOnDelivery_001() {
		Logger.start(true, "真实40件，虚拟30件，发货十件货-----真实30件，虚拟30件");
		try {
			//case 验证有问题，与强华沟通 发货出库只在mysql stockmgr库中的agentInventrySku表中的inum等于出库的负数
			
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			addAgentProductBean.getCatalogList().get(0).setVirtualStock(30);
			addAgentProductBean.getCatalogList().get(0).setStock(40);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ProductDetailsDto productDetailsDto = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);
			stockoutondeliveryBean.setOrderId(Long.parseLong(TestDataManager.getRandomNum(10)));
			stockoutondeliveryBean.setRemark("发货十件货");
			CatalogDto ca = new CatalogDto();
			ca.setNum(10);
			stockoutondeliveryBean.setSellerId(rootUserId);
			ca.setCatalogId(productDetailsDto.getCatalogList().get(0).getCatalogId());
			ca.setProductId(productId);
			stockoutondeliveryBean.setCatalogList(Arrays.asList(ca));
			stockoutondeliveryCall.setData(stockoutondeliveryBean);
			stockoutondeliveryCall.callService();
			
			example.createCriteria().andProductIdEqualTo(productId).andCatalogIdEqualTo(productDetailsDto.getCatalogList().get(0).getCatalogId());
			//example.createCriteria().andProductIdEqualTo("p3206649").andCatalogIdEqualTo("c5796809");
			agentinventorysku sk=sku.selectByExample(example).get(0);
			
			Logger.verifyEquals(ca.getNum(),
					sk.getNum()*-1, "验证库存");
			
			/*ProductDetailsDto productDetailsDto2 = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);

			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getStock() - 10,
					productDetailsDto2.getCatalogList().get(0).getStock(), "验证库存");
			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getRealStock() - 10,
					productDetailsDto2.getCatalogList().get(0).getRealStock(), "验证真实库存");
			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getVirtualStock(),
					productDetailsDto2.getCatalogList().get(0).getVirtualStock(), "验证虚拟库存");*/

		} catch (Exception e) {
			Logger.fail(e);
		}

	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_StockOutOnDelivery_002() {
		Logger.start(true, "真实40件，虚拟30件，发货40件货-----真实0件，虚拟30件");
		try {

			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			addAgentProductBean.getCatalogList().get(0).setVirtualStock(30);
			addAgentProductBean.getCatalogList().get(0).setStock(40);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ProductDetailsDto productDetailsDto = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);

			stockoutondeliveryBean.setOrderId(Long.parseLong(TestDataManager.getRandomNum(10)));
			CatalogDto ca = new CatalogDto();
			stockoutondeliveryBean.setSellerId(rootUserId);
			ca.setNum(40);
			ca.setCatalogId(productDetailsDto.getCatalogList().get(0).getCatalogId());
			ca.setProductId(productId);
			stockoutondeliveryBean.setCatalogList(Arrays.asList(ca));
			stockoutondeliveryBean.setCatalogList(Arrays.asList(ca));
			stockoutondeliveryCall.setData(stockoutondeliveryBean);
			stockoutondeliveryCall.callService();
			example.createCriteria().andProductIdEqualTo(productId).andCatalogIdEqualTo(productDetailsDto.getCatalogList().get(0).getCatalogId());
			//example.createCriteria().andProductIdEqualTo("p3206649").andCatalogIdEqualTo("c5796809");
			agentinventorysku sk=sku.selectByExample(example).get(0);
			
			Logger.verifyEquals(ca.getNum(),
					sk.getNum()*-1, "验证库存");

			/*ProductDetailsDto productDetailsDto2 = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);

			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getStock() - 40,
					productDetailsDto2.getCatalogList().get(0).getStock(), "验证库存");
			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getRealStock() - 40,
					productDetailsDto2.getCatalogList().get(0).getRealStock(), "验证真实库存");
			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getVirtualStock(),
					productDetailsDto2.getCatalogList().get(0).getVirtualStock(), "验证虚拟库存");*/

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_StockOutOnDelivery_003() {
		Logger.start(true, "真实40件，虚拟30件，发货50件货-----真实0件，虚拟20件");
		try {

			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			addAgentProductBean.getCatalogList().get(0).setVirtualStock(30);
			addAgentProductBean.getCatalogList().get(0).setStock(40);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ProductDetailsDto productDetailsDto = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);

			stockoutondeliveryBean.setOrderId(Long.parseLong(TestDataManager.getRandomNum(10)));
			CatalogDto ca = new CatalogDto();
			stockoutondeliveryBean.setSellerId(rootUserId);
			ca.setNum(50);
			ca.setCatalogId(productDetailsDto.getCatalogList().get(0).getCatalogId());
			ca.setProductId(productId);
			stockoutondeliveryBean.setCatalogList(Arrays.asList(ca));
			stockoutondeliveryBean.setCatalogList(Arrays.asList(ca));
			stockoutondeliveryCall.setData(stockoutondeliveryBean);
			stockoutondeliveryCall.callService();
			
			
			example.createCriteria().andProductIdEqualTo(productId).andCatalogIdEqualTo(productDetailsDto.getCatalogList().get(0).getCatalogId());
			agentinventorysku sk=sku.selectByExample(example).get(0);
			
			Logger.verifyEquals(ca.getNum(),
					sk.getNum()*-1, "验证库存");
			

			/*ProductDetailsDto productDetailsDto2 = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);

			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getStock() - 50,
					productDetailsDto2.getCatalogList().get(0).getStock(), "验证库存");
			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getRealStock() - 40,
					productDetailsDto2.getCatalogList().get(0).getRealStock(), "验证真实库存");
			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getVirtualStock() - 10,
					productDetailsDto2.getCatalogList().get(0).getVirtualStock(), "验证虚拟库存");*/

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_StockOutOnDelivery_004() {
		Logger.start(true, "真实40件，虚拟30件，发货70件货-----真实0件，虚拟0件");
		try {

			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			addAgentProductBean.getCatalogList().get(0).setVirtualStock(30);
			addAgentProductBean.getCatalogList().get(0).setStock(40);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ProductDetailsDto productDetailsDto = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);

			stockoutondeliveryBean.setOrderId(Long.parseLong(TestDataManager.getRandomNum(10)));
			CatalogDto ca = new CatalogDto();
			stockoutondeliveryBean.setSellerId(rootUserId);
			ca.setNum(70);
			ca.setCatalogId(productDetailsDto.getCatalogList().get(0).getCatalogId());
			ca.setProductId(productId);
			stockoutondeliveryBean.setCatalogList(Arrays.asList(ca));
			stockoutondeliveryBean.setCatalogList(Arrays.asList(ca));
			stockoutondeliveryCall.setData(stockoutondeliveryBean);
			stockoutondeliveryCall.callService();
			
			example.createCriteria().andProductIdEqualTo(productId).andCatalogIdEqualTo(productDetailsDto.getCatalogList().get(0).getCatalogId());
			agentinventorysku sk=sku.selectByExample(example).get(0);
			
			Logger.verifyEquals(ca.getNum(),
					sk.getNum()*-1, "验证库存");
			
			/*ProductDetailsDto productDetailsDto2 = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);

			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getStock() - 70,
					productDetailsDto2.getCatalogList().get(0).getStock(), "验证库存");
			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getRealStock() - 40,
					productDetailsDto2.getCatalogList().get(0).getRealStock(), "验证真实库存");
			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getVirtualStock() - 30,
					productDetailsDto2.getCatalogList().get(0).getVirtualStock(), "验证虚拟库存");*/
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_StockOutOnDelivery_005() {
		Logger.start(true, "真实40件，虚拟30件，发货80件货-----真实+虚拟不够80，失败");
		try {

			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			addAgentProductBean.getCatalogList().get(0).setVirtualStock(30);
			addAgentProductBean.getCatalogList().get(0).setStock(40);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ProductDetailsDto productDetailsDto = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);

			stockoutondeliveryBean.setOrderId(Long.parseLong(TestDataManager.getRandomNum(10)));
			CatalogDto ca = new CatalogDto();
			stockoutondeliveryBean.setSellerId(rootUserId);
			ca.setNum(80);
			ca.setCatalogId(productDetailsDto.getCatalogList().get(0).getCatalogId());
			ca.setProductId(productId);
			stockoutondeliveryBean.setCatalogList(Arrays.asList(ca));
			stockoutondeliveryBean.setCatalogList(Arrays.asList(ca));
			stockoutondeliveryCall.setData(stockoutondeliveryBean);
			stockoutondeliveryCall.callService();
			
			example.createCriteria().andProductIdEqualTo(productId).andCatalogIdEqualTo(productDetailsDto.getCatalogList().get(0).getCatalogId());
			agentinventorysku sk=sku.selectByExample(example).get(0);
			
			Logger.verifyEquals(ca.getNum(),
					sk.getNum()*-1, "验证库存");
			
			//Logger.verifyEquals("400", stockoutondeliveryCall.getString("Code"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_StockOutOnDelivery_006() {
		Logger.start(true, "订单号为空，失败");
		try {

			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			addAgentProductBean.getCatalogList().get(0).setVirtualStock(30);
			addAgentProductBean.getCatalogList().get(0).setStock(40);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ProductDetailsDto productDetailsDto = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);

			CatalogDto ca = new CatalogDto();
			stockoutondeliveryBean.setSellerId(rootUserId);
			ca.setNum(10);
			ca.setCatalogId(productDetailsDto.getCatalogList().get(0).getCatalogId());
			ca.setProductId(productId);
			stockoutondeliveryBean.setCatalogList(Arrays.asList(ca));
			stockoutondeliveryBean.setCatalogList(Arrays.asList(ca));
			stockoutondeliveryCall.setData(stockoutondeliveryBean);
			stockoutondeliveryCall.callService();
			

			ProductDetailsDto productDetailsDto2 = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);
			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getStock(),
					productDetailsDto2.getCatalogList().get(0).getStock(), "验证库存");
			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getRealStock(),
					productDetailsDto2.getCatalogList().get(0).getRealStock(), "验证真实库存");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_StockOutOnDelivery_007() {
		Logger.start(true, "买家id为空，失败");
		try {

			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			addAgentProductBean.getCatalogList().get(0).setVirtualStock(30);
			addAgentProductBean.getCatalogList().get(0).setStock(40);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ProductDetailsDto productDetailsDto = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);

			stockoutondeliveryBean.setOrderId(Long.parseLong(TestDataManager.getRandomNum(10)));
			CatalogDto ca = new CatalogDto();
			ca.setNum(10);
			ca.setCatalogId(productDetailsDto.getCatalogList().get(0).getCatalogId());
			ca.setProductId(productId);
			stockoutondeliveryBean.setCatalogList(Arrays.asList(ca));
			stockoutondeliveryBean.setCatalogList(Arrays.asList(ca));
			stockoutondeliveryCall.setData(stockoutondeliveryBean);
			stockoutondeliveryCall.callService();
			

			ProductDetailsDto productDetailsDto2 = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);

			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getStock(),
					productDetailsDto2.getCatalogList().get(0).getStock(), "验证库存");
			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getRealStock(),
					productDetailsDto2.getCatalogList().get(0).getRealStock(), "验证真实库存");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_StockOutOnDelivery_008() {
		Logger.start(true, "库存数为负数，失败");
		try {

			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			addAgentProductBean.getCatalogList().get(0).setVirtualStock(30);
			addAgentProductBean.getCatalogList().get(0).setStock(40);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ProductDetailsDto productDetailsDto = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);

			stockoutondeliveryBean.setOrderId(Long.parseLong(TestDataManager.getRandomNum(10)));
			CatalogDto ca = new CatalogDto();
			stockoutondeliveryBean.setSellerId(rootUserId);
			ca.setNum(-10);
			ca.setCatalogId(productDetailsDto.getCatalogList().get(0).getCatalogId());
			ca.setProductId(productId);
			stockoutondeliveryBean.setCatalogList(Arrays.asList(ca));
			stockoutondeliveryBean.setCatalogList(Arrays.asList(ca));
			stockoutondeliveryCall.setData(stockoutondeliveryBean);
			stockoutondeliveryCall.callService();
			

			ProductDetailsDto productDetailsDto2 = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);

			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getStock(),
					productDetailsDto2.getCatalogList().get(0).getStock(), "验证库存");
			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getRealStock(),
					productDetailsDto2.getCatalogList().get(0).getRealStock(), "验证真实库存");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_StockOutOnDelivery_009() {
		Logger.start(true, "库存数为0失败");
		try {

			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			addAgentProductBean.getCatalogList().get(0).setVirtualStock(30);
			addAgentProductBean.getCatalogList().get(0).setStock(40);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ProductDetailsDto productDetailsDto = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);

			stockoutondeliveryBean.setOrderId(Long.parseLong(TestDataManager.getRandomNum(10)));
			CatalogDto ca = new CatalogDto();
			stockoutondeliveryBean.setSellerId(rootUserId);
			ca.setNum(0);
			ca.setCatalogId(productDetailsDto.getCatalogList().get(0).getCatalogId());
			ca.setProductId(productId);
			stockoutondeliveryBean.setCatalogList(Arrays.asList(ca));
			stockoutondeliveryBean.setCatalogList(Arrays.asList(ca));
			stockoutondeliveryCall.setData(stockoutondeliveryBean);
			stockoutondeliveryCall.callService();
			

			ProductDetailsDto productDetailsDto2 = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);

			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getStock(),
					productDetailsDto2.getCatalogList().get(0).getStock(), "验证库存");
			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getRealStock(),
					productDetailsDto2.getCatalogList().get(0).getRealStock(), "验证真实库存");

			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_StockOutOnDelivery_010() {
		Logger.start(true, "商品id为空");
		try {

			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			addAgentProductBean.getCatalogList().get(0).setVirtualStock(30);
			addAgentProductBean.getCatalogList().get(0).setStock(40);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ProductDetailsDto productDetailsDto = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);

			stockoutondeliveryBean.setOrderId(Long.parseLong(TestDataManager.getRandomNum(10)));
			CatalogDto ca = new CatalogDto();
			stockoutondeliveryBean.setSellerId(rootUserId);
			ca.setNum(10);
			ca.setCatalogId(productDetailsDto.getCatalogList().get(0).getCatalogId());
			stockoutondeliveryBean.setCatalogList(Arrays.asList(ca));
			stockoutondeliveryBean.setCatalogList(Arrays.asList(ca));
			stockoutondeliveryCall.setData(stockoutondeliveryBean);
			stockoutondeliveryCall.callService();
			

			ProductDetailsDto productDetailsDto2 = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);

			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getStock(),
					productDetailsDto2.getCatalogList().get(0).getStock(), "验证库存");
			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getRealStock(),
					productDetailsDto2.getCatalogList().get(0).getRealStock(), "验证真实库存");

			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_StockOutOnDelivery_011() {
		Logger.start(true, "商品规格为空");
		try {

			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			addAgentProductBean.getCatalogList().get(0).setVirtualStock(30);
			addAgentProductBean.getCatalogList().get(0).setStock(40);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ProductDetailsDto productDetailsDto = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);

			stockoutondeliveryBean.setOrderId(Long.parseLong(TestDataManager.getRandomNum(10)));
			CatalogDto ca = new CatalogDto();
			stockoutondeliveryBean.setSellerId(rootUserId);
			ca.setNum(10);
			ca.setProductId(productId);
			stockoutondeliveryBean.setCatalogList(Arrays.asList(ca));
			stockoutondeliveryBean.setCatalogList(Arrays.asList(ca));
			stockoutondeliveryCall.setData(stockoutondeliveryBean);
			stockoutondeliveryCall.callService();
			

			ProductDetailsDto productDetailsDto2 = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);

			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getStock(),
					productDetailsDto2.getCatalogList().get(0).getStock(), "验证库存");
			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getRealStock(),
					productDetailsDto2.getCatalogList().get(0).getRealStock(), "验证真实库存");

			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_StockOutOnDelivery_012() {
		Logger.start(true, "商品id与规格id不匹配，失败");
		try {

			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			addAgentProductBean.getCatalogList().get(0).setVirtualStock(30);
			addAgentProductBean.getCatalogList().get(0).setStock(40);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ProductDetailsDto productDetailsDto = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);

			AddAgentProductBean addAgentProductBean1 = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			addAgentProductBean.getCatalogList().get(0).setVirtualStock(30);
			addAgentProductBean.getCatalogList().get(0).setStock(40);
			String productId1 = AddAgentProductCallService.AddAgentProduct(addAgentProductBean1);
			ProductDetailsDto productDetails = AddAgentProductCallService.selectProductDetails(rootUserId, productId1);

			stockoutondeliveryBean.setOrderId(Long.parseLong(TestDataManager.getRandomNum(10)));
			CatalogDto ca = new CatalogDto();
			stockoutondeliveryBean.setSellerId(rootUserId);
			ca.setNum(10);
			ca.setCatalogId(productDetails.getCatalogList().get(0).getCatalogId());
			ca.setProductId(productId+1);
			stockoutondeliveryBean.setCatalogList(Arrays.asList(ca));
			stockoutondeliveryCall.setData(stockoutondeliveryBean);
			stockoutondeliveryCall.callService();
			
			example.createCriteria().andProductIdEqualTo(productId).andCatalogIdEqualTo(productDetailsDto.getCatalogList().get(0).getCatalogId());
			
			Logger.verifyEquals(0,
					sku.selectByExample(example).size(), "验证数据库无数据");
			
			/*Logger.verifyEquals(200, stockoutondeliveryCall.getJsonObject().get("Code").getAsString(), "验证code");

			ProductDetailsDto productDetailsDto2 = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);

			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getStock(),
					productDetailsDto2.getCatalogList().get(0).getStock(), "验证库存");
			Logger.verifyEquals(productDetailsDto.getCatalogList().get(0).getRealStock(),
					productDetailsDto2.getCatalogList().get(0).getRealStock(), "验证真实库存");*/

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

}